package com.Multi_threaded;

import java.util.Arrays;
import java.util.Scanner;

public class test1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] n=new int[sc.nextInt()];
        for (int i = 0; i < n.length; i++) {
            n[i]=sc.nextInt();
        }
        Arrays.sort(n);
        int temp=0;
        for (int i = 0; i < n.length-2; i++) {
            for (int j = i+1; j <n.length-1 ; j++) {
                int sum=n[i]+n[j];
                for (int k = j+1; k < n.length; k++) {
                    if (sum==n[k]&&i!=j){
                        temp++;
                    }
                }
            }
        }
        System.out.println(temp);
    }
}
